//引入Swagger
import { NestExpressApplication } from '@nestjs/platform-express';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';

export default function installSwagger(port: number, app: NestExpressApplication) {
    //配置swagger
    const swaggerOptions = new DocumentBuilder()
        .setTitle('nestjs-api-文档')  //文档标题
        .setDescription('nestjs-api-说明')  //文档描述
        .setVersion('1.0')  //文档版本
        .addBearerAuth() //鉴权，可以输入token
        .build(); //创建

    //创建swagger
    const document = SwaggerModule.createDocument(app, swaggerOptions);

    //启动swagger
    SwaggerModule.setup(process.env.DOC_API, app, document); //访问路径为 localhost:8000/doc
}